Skip to content

Gracefully skip parsing errors when source files use unsupported encoding#754

Merged
uhafner merged 5 commits into
jenkinsci:mainfrom
akash-manna-sky:issue-678
Jun 2, 2026
Merged

Gracefully skip parsing errors when source files use unsupported encoding#754
uhafner merged 5 commits into
jenkinsci:mainfrom
akash-manna-sky:issue-678

Conversation

@akash-manna-sky
Copy link
Copy Markdown
Contributor

Coverage paint fails for files containing extended ascii characters

Fixes #678

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@github-actions github-actions Bot requested a review from uhafner May 21, 2026 18:51
@uhafner uhafner added the bug Bugs or performance problems label Jun 1, 2026
Copy link
Copy Markdown
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! I'm not sure if it skips the characters or if renders them correctly now? Can you add an assertion that makes it clear what is the new output?

}

private List<String> readSourceLines(final Path sourcePath, final Charset charset) throws IOException {
try (var reader = new java.io.BufferedReader(new InputStreamReader(Files.newInputStream(sourcePath),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try (var reader = new java.io.BufferedReader(new InputStreamReader(Files.newInputStream(sourcePath),
try (var reader = new BufferedReader(new InputStreamReader(Files.newInputStream(sourcePath),

Path sourceFile = workspace.resolve("Example.m");
Files.write(sourceFile, List.of(
"function y = example()",
"% Copyright 2026, Caf\u00e9 Corporation",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"% Copyright 2026, Caf\u00e9 Corporation",
"% Copyright 2026, Café Corporation",

@github-actions github-actions Bot requested a review from uhafner June 2, 2026 07:53
Copy link
Copy Markdown
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way too complex. Please simplify.

Comment on lines +64 to +75
byte[] paintedBytes = readPaintedBytesFromNestedZip(outerZipPath);

assertThat(containsBytes(paintedBytes, CAFE_NBSP_CORPORATION_UTF8))
.as("Painted HTML must contain UTF-8 bytes for 'Cafe-acute NBSP Corporation' "
+ "(43 61 66 C3 A9 C2 A0 43 6F 72 70 6F 72 61 74 69 6F 6E). "
+ "Actual painted bytes: " + toHex(paintedBytes))
.isTrue();

assertThat(containsBytes(paintedBytes, REPLACEMENT_CHAR_UTF8))
.as("Painted HTML must NOT contain UTF-8 replacement character EF BF BD "
+ "— that would mean 0xE9 was not decoded correctly as windows-1252")
.isFalse();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify that code with (and remove the byte handling):

       var renderedText = new String(paintedBytes, StandardCharsets.UTF_8).replace("\u00A0", " ");
       assertThat(renderedText).contains("Copyright 2026, Café Corporation");

@github-actions github-actions Bot requested a review from uhafner June 2, 2026 12:05
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

☀️   Quality Monitor

Tests

   JUnit   Unit Tests: ✅ successful — 192 passed $\color{green}{\textsf{(+1)}}$
   🚀   Integration Tests: ✅ successful — 148 passed $\textsf{(±0)}$, 7 skipped $\textsf{(±0)}$
   ⛔   Architecture Tests: ✅ successful — 15 passed $\textsf{(±0)}$

Coverage for New Code

   〰️   Line Coverage: 100.00% $\color{green}{\textsf{(+57.14)}}$ — perfect 🎉
   ➰   Branch Coverage: 100.00% $\color{green}{\textsf{(+66.67)}}$ — perfect 🎉

Coverage for Whole Project

   〰️   Line Coverage: 76.88% $\color{green}{\textsf{(+0.55)}}$ — 710 missed lines
   ➰   Branch Coverage: 66.93% $\color{green}{\textsf{(+0.34)}}$ — 290 missed branches

Style

   CheckStyle   CheckStyle: No warnings $\textsf{(±0)}$
   PMD   PMD: No warnings $\textsf{(±0)}$
   ☕   Java Compiler: No warnings $\textsf{(±0)}$

Bugs

   SpotBugs   SpotBugs: No bugs $\textsf{(±0)}$
   🐛   Error Prone: No bugs $\textsf{(±0)}$

Vulnerabilities

   🛡️   OWASP Dependency Check: 201 vulnerabilities $\color{green}{\textsf{(+201)}}$ — error: 16, high: 50, normal: 128, low: 7

Software Metrics

   🌀   Cyclomatic Complexity: 1032 (total)
   💭   Cognitive Complexity: 564 (total)
   ➿   N-Path Complexity: 1388 (total)
   📏   Lines of Code: 12080 (total)
   📝   Non Commenting Source Statements: 4076 (total)
   🔗   Class Cohesion: 100.00% (maximum)
   ⚖️   Weight of Class: 100.00% (maximum)

📌 Reference Results

Delta reports computed against the reference results of c0a47c7 in workflow run 26680624830.

🚦 Quality Gates

Overall Status: ✅ SUCCESS

✅ Passed Gates

  • ✅ Overall Tests Success Rate: 100.00 >= 100.00
  • ✅ Line Coverage in New Code: 100.00 >= 90.00
  • ✅ Branch Coverage in New Code: 100.00 >= 90.00
  • ✅ Potential Bugs in Whole Project: 0.00 <= 0.00
  • ✅ Style Violation in Whole Project: 0.00 <= 0.00

Created by Quality Monitor v4.14.3 (#a8d815d). More details are shown in the GitHub Checks Result.

@uhafner uhafner changed the title Coverage paint fails for files containing extended ascii characters Gracefully skip parsing errors when source files use unsupported encoding Jun 2, 2026
@uhafner uhafner merged commit 1be6666 into jenkinsci:main Jun 2, 2026
31 checks passed
@akash-manna-sky akash-manna-sky deleted the issue-678 branch June 2, 2026 17:46
@akash-manna-sky
Copy link
Copy Markdown
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bugs or performance problems

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coverage paint fails for files containing extended ascii characters

2 participants